#ifndef CPOINT_H
#define CPOINT_H

#include <stdlib.h>
#include <iostream>
#include <vector>
using namespace std;

enum CPOINT_COORDENATES {X,Y,Z};

template <typename _TO, int _SIZE = 2>
class CPoint {
	typedef _TO  value_t;
protected:
	vector<value_t> _coordenate;
	
public:
	CPoint (const value_t& _x = NULL, const value_t& _y = NULL) {
		_coordenate.push_back(_x); 
		_coordenate.push_back(_y); 
	}

	~CPoint (void){
	}

	bool operator == (const CPoint& p){
		return _coordenate[X] == p._coordenate[X] && _coordenate[Y] == p._coordenate[Y];
	}

	value_t& operator[] (const int& __pos){
		try{
			if (__pos > _SIZE) throw __pos % _SIZE;
			if (__pos < 0) throw (-1 * __pos) % _SIZE;
			else return _coordenate[__pos];
		} catch (int __new_pos) {
			return _coordenate[__new_pos];
		}
	}
	
	template <typename __TO>
	friend ostream& operator<< (ostream& out, const CPoint<__TO>& __point){
		out << __point._coordenate[X] << "," << __point._coordenate[Y];
		return out;
	}
	
};


#endif